package com.cenxi.controller;

import com.cenxi.common.result.Resp;
import com.cenxi.dao.manage.ManageMediaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @Author cenxi
 * @Date 2023/11/14 17:39
 * @Version 1.0
 */
@Api(tags = "多媒体接口")
@RestController
@RequestMapping("/media")
public class MediaController {

    @Autowired
    private ManageMediaService manageMediaService;

    @PostMapping("/upload")
    @ApiOperation(value = "文件上传")
    public Resp<String> upload(@RequestParam("file") MultipartFile file) {
        return Resp.succeed(manageMediaService.upload(file));
    }

    @GetMapping("/getDomainName")
    @ApiOperation(value = "获取文件域名")
    public Resp<Object> getDomainName() {
//        List<List<List<String>>> label = new ArrayList<>();
//        List<List<String>> l = new ArrayList<>();
//        List<String> l1 = new ArrayList<>();
//        List<String> l2 = new ArrayList<>();
//        Collections.addAll(l1, "测", "是", "哈哈" , "a", "b", "c");
//        Collections.addAll(l2, "a", "b", "c" , "测", "是", "哈哈");
//        l.add(l1);
//        l.add(l2);
//        label.add(l);
        return Resp.succeed(manageMediaService.getDomainName());
    }

}
